package com.edou.base.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.json.simple.parser.JSONParser;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

/**
 * 图片裁剪公共方法
 * @creator     admin
 * @create-time 2016/3/12 16:10:22
 * @email admin@edou.com
 * @company www.edou.com
 * @version 1.0
 */
@Controller("ImageCropController")
@Scope("prototype")
@RequestMapping("/")
public class ImageCropController extends BaseController {

	/**
	 * 跳转到图片裁剪的页面
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/image_crop.htm", method = {RequestMethod.POST, RequestMethod.GET})
	public ModelAndView imageCrop(HttpServletRequest request, HttpServletResponse response, HttpSession session) throws Exception {
		ModelAndView view = new ModelAndView();
		JSONParser p = new JSONParser();
		view.setViewName("/base/jcrop/image_crop");
		String postData = (String)request.getParameter("postData");
		view.addObject("postData",p.parse(postData));
		return view;
	}
	
}